<template>
    <div>
        <div class="list" v-for=" item in list" :key="item.id" @click="toEdit(item.id)">
            <div>
                <span class="fs28">{{item.changeRemark}}</span>
                <p class="cnt">{{item.changeNum >= 0 ? '+' + item.changeNum : item.changeNum}}</p>
            </div>
            <div>
                <!-- <p class="price">金额：100元</p> -->
                <span class="fs24 color-999">{{item.createTime}}</span>
            </div>
        </div>
        <pub-list-end :loading="scroll.loading" :max="scroll.max" :noData="scroll.noData"></pub-list-end>
    </div>
</template>

<script>
import { getUserCodeCntChangeHis } from '@/request/house'
export default {
    name: "",
    components: {},
    data() {
        return {
            list: [],
            scroll: {
                page: 1,
                size: 14,
                loading: false,
                max: false,
                noData: false,
            },
            
        }
    },
    onLoad() {
        this.onRefresh()
    },
    
    onPullDownRefresh() {
        this.onRefresh()
    },
    onReachBottom() {
        this.onInfinite()
    },
    methods: {
        getList(complete) {
            getUserCodeCntChangeHis({
                codeId: this.codeId,
                shareFlag: this.actTab, //00未分享，01已分享
                pageIndex: this.scroll.page,
                pageSize: this.scroll.size,
            }, { complete }).then(res => {
                if(this.scroll.page == 1) {
                    this.list = res.data.list
                } else {
                    this.list = this.list.concat(res.data.list)
                }
                this.scroll.max = this.list.length >= res.data.total
                this.scroll.noData = res.data.total == 0
            })
        },
        // 重头第一页刷新列表
        onRefresh() {
            this.scroll.loading = true
            this.scroll.max = false
            this.scroll.noData = false
            this.scroll.page = 1
            this.list = []
            this.getList(() => {
                this.scroll.loading = false;
                uni.stopPullDownRefresh()
            })
        },
        // 滚动到底部加载
        onInfinite() {
            if(this.scroll.loading || this.scroll.max) return
            this.scroll.loading = true
            this.scroll.page += 1
            this.getList(() => {
                this.scroll.loading = false
            })
        }
    }
}
</script>
<style lang="less" scoped>
.list{
    width: 700rpx;
    background: #fff;
    border-radius: 15rpx;
    margin: 15rpx auto;
    box-shadow: 1px 1px 10rpx #ddd;
    padding: 25rpx 20rpx;
    position: relative;
    div{
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 5rpx;
        &:last-child{
            margin-bottom: 0;
        }
        .cnt{
            font-size: 32rpx;
            font-weight: bold;
        }
        .price{
            font-size: 28rpx;
            color: @mainColor;
        }
    }
}


</style>